package controller

import (
	"test-gin/service/test"

	"github.com/gin-gonic/gin"
)

type TestRes struct {
	Message string  `json:"message"`
	Id      int     `json:"id"`
	Name    *string `json:"name"`
	Age     *int    `json:"age"`
}

func InitTestController(r *gin.Engine) {
	// 随机JSON接口
	r.GET("/test-gin/test/random", GenerateRandomJson2)
	r.GET("/test-gin/test/json", func(c *gin.Context) {
		name := "123"
		testRes := TestRes{
			Message: "Hello, World!",
			Id:      1,
			Name:    &name,
		}
		c.JSON(200, testRes)
	})

}

func GenerateRandomJson2(c *gin.Context) {
	c.JSON(200, test.GetTestService().GetRandomData())
}
